package com.sunny;

import java.io.*;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;

public class FileNioWrite {

    public static void main(String[] args) {

        File file = new File("bbb");
        try (FileOutputStream fout = new FileOutputStream(file)){
            FileChannel fc = fout.getChannel();
            ByteBuffer bb = Charset.forName("utf8").encode("中guo人asdfasdfasdf阿斯顿发送到");
            while (fc.write(bb) != 0);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
